<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="租户管理系统 - 首页">
    <title>租户管理系统 - 首页</title>
    <!-- 引入最新版 Bootstrap -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- 引入最新版 Font Awesome -->
    <link href="https://cdn.jsdelivr.net/npm/font-awesome@6.5.2/css/all.min.css" rel="stylesheet">
    <!-- 引入Chart.js -->
    <script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.0/dist/chart.umd.min.js"></script>
    <style>
        /* CSS Variables - 与平台端保持一致 */
        :root {
            --primary-color: #4f46e5;
            --secondary-color: #2c3e50;
            --success-color: #27ae60;
            --danger-color: #e74c3c;
            --warning-color: #f39c12;
            --info-color: #17a2b8;
            --light-bg: #f5f7fa;
            --dark-bg: #2c3e50;
            --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
            --transition: all 0.3s ease;
        }

        /* Global Styles */
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Microsoft YaHei', Arial, sans-serif;
            background-color: var(--light-bg);
            color: #333;
            line-height: 1.6;
        }

        /* Loader */
        .loader {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: var(--primary-color);
            display: flex;
            justify-content: center;
            align-items: center;
            z-index: 9999;
            transition: opacity 0.5s ease, visibility 0.5s ease;
        }

        .loader.hidden {
            opacity: 0;
            visibility: hidden;
        }

        .loader::after {
            content: '';
            width: 50px;
            height: 50px;
            border: 5px solid #fff;
            border-top-color: transparent;
            border-radius: 50%;
            animation: spin 1s linear infinite;
        }

        @keyframes spin {
            to {
                transform: rotate(360deg);
            }
        }

        /* Main Container */
        .main-container {
            display: flex;
            min-height: 100vh;
        }

        /* Sidebar */
        .sidebar {
            width: 280px;
            background-color: #2c3e50;
            box-shadow: var(--card-shadow);
            transition: var(--transition);
            position: fixed;
            height: 100vh;
            overflow-y: auto;
            z-index: 100;
            color: white;
        }

        .sidebar.collapsed {
            width: 80px;
        }

        .sidebar.collapsed .logo-text {
            display: none;
        }

        .sidebar.collapsed .sidebar-header {
            justify-content: center;
        }

        .sidebar.collapsed .sidebar-nav a {
            justify-content: center;
            padding: 12px 0;
            font-size: 0;
        }

        .sidebar.collapsed .sidebar-nav a i {
            margin-right: 0;
            font-size: 16px;
        }

        /* Sidebar Header */
        .sidebar-header {
            padding: 1.5rem;
            display: flex;
            align-items: center;
            justify-content: space-between;
            border-bottom: 1px solid #34495e;
        }

        .logo {
            display: flex;
            align-items: center;
            gap: 0.75rem;
        }

        .logo-icon {
            width: 40px;
            height: 40px;
            background: linear-gradient(135deg, var(--primary-color), #818cf8);
            border-radius: 8px;
            display: flex;
            align-items: center;
            justify-content: center;
            color: #fff;
            font-size: 1.5rem;
            font-weight: bold;
        }

        .logo-text {
            font-size: 1.25rem;
            font-weight: 700;
            color: white;
        }

        .sidebar-toggle {
            background: none;
            border: none;
            font-size: 1.25rem;
            color: white;
            cursor: pointer;
            padding: 0.5rem;
            border-radius: 4px;
            transition: var(--transition);
        }

        .sidebar-toggle:hover {
            background-color: #34495e;
            color: white;
        }

        /* Sidebar Navigation */
        .sidebar-nav {
            padding: 1rem 0;
        }

        .nav-item {
            margin-bottom: 0.25rem;
        }

        .nav-link {
            display: flex;
            align-items: center;
            gap: 0.75rem;
            padding: 0.75rem 1.5rem;
            color: white;
            text-decoration: none;
            transition: var(--transition);
            border-left: 3px solid transparent;
        }

        .nav-link:hover {
            background-color: #34495e;
            border-left-color: var(--primary-color);
        }

        .nav-link.active {
            background-color: #34495e;
            color: white;
            border-left-color: var(--primary-color);
            font-weight: 500;
        }

        .nav-icon {
            font-size: 1.125rem;
            width: 20px;
            text-align: center;
        }

        .nav-text {
            font-weight: 500;
        }

        /* Main Content */
        .main-content {
            flex: 1;
            margin-left: 280px;
            transition: var(--transition);
        }

        .main-content.expanded {
            margin-left: 80px;
        }

        /* Top Navigation */
        .top-nav {
            background-color: #fff;
            box-shadow: var(--card-shadow);
            padding: 1rem 2rem;
            display: flex;
            align-items: center;
            justify-content: space-between;
            position: sticky;
            top: 0;
            z-index: 99;
        }

        .nav-left {
            display: flex;
            align-items: center;
            gap: 1rem;
        }

        .nav-right {
            display: flex;
            align-items: center;
            gap: 1rem;
        }

        .search-box {
            position: relative;
        }

        .search-box i {
            position: absolute;
            left: 0.75rem;
            top: 50%;
            transform: translateY(-50%);
            color: #666;
        }

        .search-box input {
            padding: 0.5rem 0.75rem 0.5rem 2.5rem;
            border: 1px solid #e0e0e0;
            border-radius: 4px;
            font-size: 0.875rem;
            width: 300px;
            transition: var(--transition);
        }

        .search-box input:focus {
            outline: none;
            border-color: var(--primary-color);
            box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.25);
        }

        .notification-icon {
            position: relative;
            font-size: 1.25rem;
            color: #666;
            cursor: pointer;
            transition: var(--transition);
        }

        .notification-icon:hover {
            color: var(--primary-color);
        }

        .notification-badge {
            position: absolute;
            top: -5px;
            right: -5px;
            background-color: var(--danger-color);
            color: white;
            font-size: 0.75rem;
            width: 20px;
            height: 20px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .user-info {
            display: flex;
            align-items: center;
            gap: 0.75rem;
            cursor: pointer;
            transition: var(--transition);
            padding: 0.5rem;
            border-radius: 4px;
        }

        .user-info:hover {
            background-color: #f0f0f0;
        }

        .user-avatar {
            width: 40px;
            height: 40px;
            background: linear-gradient(135deg, var(--primary-color), #818cf8);
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            color: white;
            font-weight: bold;
            font-size: 0.875rem;
        }

        .user-details {
            display: flex;
            flex-direction: column;
        }

        .user-name {
            font-weight: 500;
            font-size: 0.875rem;
        }

        .user-role {
            font-size: 0.75rem;
            color: #666;
        }

        /* Content Area */
        .content {
            padding: 2rem;
        }

        .page-title {
            margin-bottom: 2rem;
        }

        .page-title h1 {
            font-size: 2rem;
            font-weight: 700;
            color: var(--dark-bg);
        }

        /* Stats Grid */
        .stats-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
            gap: 1.5rem;
            margin-bottom: 2rem;
        }

        .stat-card {
            background-color: #fff;
            padding: 1.5rem;
            border-radius: 8px;
            box-shadow: var(--card-shadow);
            transition: var(--transition);
        }

        .stat-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
        }

        .stat-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 1rem;
        }

        .stat-title {
            font-size: 0.875rem;
            color: #666;
            font-weight: 500;
        }

        .stat-icon {
            width: 40px;
            height: 40px;
            border-radius: 8px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 1.25rem;
            color: white;
        }

        .stat-icon.primary {
            background-color: var(--primary-color);
        }

        .stat-icon.success {
            background-color: var(--success-color);
        }

        .stat-icon.danger {
            background-color: var(--danger-color);
        }

        .stat-icon.warning {
            background-color: var(--warning-color);
        }

        .stat-value {
            font-size: 2rem;
            font-weight: 700;
            color: var(--dark-bg);
            margin-bottom: 0.5rem;
        }

        .stat-change {
            font-size: 0.875rem;
            display: flex;
            align-items: center;
            gap: 0.25rem;
        }

        .stat-change.positive {
            color: var(--success-color);
        }

        .stat-change.negative {
            color: var(--danger-color);
        }

        /* Charts */
        .charts-container {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
            gap: 1.5rem;
            margin-bottom: 2rem;
        }

        .chart-card {
            background-color: #fff;
            padding: 1.5rem;
            border-radius: 8px;
            box-shadow: var(--card-shadow);
        }

        .chart-title {
            font-size: 1rem;
            font-weight: 600;
            color: var(--dark-bg);
            margin-bottom: 1.5rem;
        }

        .chart-wrapper {
            height: 300px;
        }

        /* Recent Activities */
        .recent-activities {
            background-color: #fff;
            padding: 1.5rem;
            border-radius: 8px;
            box-shadow: var(--card-shadow);
        }

        .activity-title {
            font-size: 1rem;
            font-weight: 600;
            color: var(--dark-bg);
            margin-bottom: 1.5rem;
        }

        .activity-list {
            display: flex;
            flex-direction: column;
            gap: 1.5rem;
        }

        .activity-item {
            display: flex;
            gap: 1rem;
        }

        .activity-avatar {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            background: linear-gradient(135deg, var(--primary-color), #818cf8);
            color: #fff;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: 600;
            flex-shrink: 0;
        }

        .activity-content {
            flex: 1;
        }

        .activity-header {
            display: flex;
            justify-content: space-between;
            align-items: flex-start;
            margin-bottom: 0.5rem;
        }

        .activity-name {
            font-weight: 600;
            color: var(--dark-bg);
        }

        .activity-time {
            font-size: 0.75rem;
            color: #666;
        }

        .activity-description {
            font-size: 0.875rem;
            color: #666;
        }

        /* Responsive Styles */
        @media (max-width: 1024px) {
            .charts-container {
                grid-template-columns: 1fr;
            }
        }

        @media (max-width: 768px) {
            .sidebar {
                transform: translateX(-100%);
            }

            .sidebar.open {
                transform: translateX(0);
            }

            .main-content {
                margin-left: 0;
            }

            .top-nav {
                padding: 1rem;
            }

            .search-box input {
                width: 200px;
            }

            .content {
                padding: 1rem;
            }

            .stats-grid {
                grid-template-columns: 1fr;
            }

            .chart-wrapper {
                height: 250px;
            }
        }

        /* Scrollbar Styles */
        ::-webkit-scrollbar {
            width: 8px;
        }

        ::-webkit-scrollbar-track {
            background: #f1f5f9;
        }

        ::-webkit-scrollbar-thumb {
            background: #cbd5e1;
            border-radius: 4px;
        }

        ::-webkit-scrollbar-thumb:hover {
            background: #94a3b8;
        }
    </style>
</head>
<body>
    <!-- 加载动画 -->
    <div class="loader"></div>

    <div class="main-container">
        <!-- 侧边栏 -->
        <aside class="sidebar" id="sidebar">
            <div class="sidebar-header">
                <div class="logo">
                    <div class="logo-icon">T</div>
                    <span class="logo-text">租户管理系统</span>
                </div>
                <button class="sidebar-toggle" id="sidebarToggle">
                    <i class="fa fa-angle-left toggle-icon"></i>
                </button>
            </div>
            <nav class="sidebar-nav">
                <a href="index.html" class="nav-link active">
                    <i class="fa fa-dashboard nav-icon"></i>
                    <span class="nav-text">首页</span>
                </a>
                <a href="dashboard.html" class="nav-link">
                    <i class="fa fa-line-chart nav-icon"></i>
                    <span class="nav-text">仪表盘</span>
                </a>
                <a href="users.html" class="nav-link">
                    <i class="fa fa-users nav-icon"></i>
                    <span class="nav-text">用户管理</span>
                </a>
                <a href="settings.html" class="nav-link">
                    <i class="fa fa-cog nav-icon"></i>
                    <span class="nav-text">租户设置</span>
                </a>
                <a href="reports.html" class="nav-link">
                    <i class="fa fa-bar-chart nav-icon"></i>
                    <span class="nav-text">报表分析</span>
                </a>
                <a href="notifications.html" class="nav-link">
                    <i class="fa fa-bell nav-icon"></i>
                    <span class="nav-text">通知中心</span>
                </a>
                <a href="../login.html" class="nav-link">
                    <i class="fa fa-sign-out nav-icon"></i>
                    <span class="nav-text">退出登录</span>
                </a>
            </nav>
        </aside>

        <!-- 主内容 -->
        <main class="main-content" id="mainContent">
            <!-- 顶部导航栏 -->
            <nav class="top-nav">
                <div class="nav-left">
                    <button class="sidebar-toggle d-md-none" id="mobileSidebarToggle">
                        <i class="fa fa-bars"></i>
                    </button>
                    <div class="search-box">
                        <i class="fa fa-search"></i>
                        <input type="text" placeholder="搜索...">
                    </div>
                </div>
                <div class="nav-right">
                    <div class="notification-icon">
                        <i class="fa fa-bell"></i>
                        <span class="notification-badge">3</span>
                    </div>
                    <div class="user-info">
                        <div class="user-avatar">JD</div>
                        <div class="user-details">
                            <div class="user-name">John Doe</div>
                            <div class="user-role">租户管理员</div>
                        </div>
                        <i class="fa fa-chevron-down"></i>
                    </div>
                </div>
            </nav>

            <!-- 内容区域 -->
            <div class="content">
                <!-- 页面标题 -->
                <div class="page-title">
                    <h1>欢迎回来，租户管理员</h1>
                </div>

                <!-- 统计卡片 -->
                <div class="stats-grid">
                    <div class="stat-card">
                        <div class="stat-header">
                            <div class="stat-title">总用户数</div>
                            <div class="stat-icon primary">
                                <i class="fa fa-users"></i>
                            </div>
                        </div>
                        <div class="stat-value">1,247</div>
                        <div class="stat-change positive">
                            <i class="fa fa-arrow-up"></i>
                            <span>+12.5% 较上月</span>
                        </div>
                    </div>

                    <div class="stat-card">
                        <div class="stat-header">
                            <div class="stat-title">活跃用户</div>
                            <div class="stat-icon success">
                                <i class="fa fa-line-chart"></i>
                            </div>
                        </div>
                        <div class="stat-value">892</div>
                        <div class="stat-change positive">
                            <i class="fa fa-arrow-up"></i>
                            <span>+8.3% 较上月</span>
                        </div>
                    </div>

                    <div class="stat-card">
                        <div class="stat-header">
                            <div class="stat-title">本月订单</div>
                            <div class="stat-icon warning">
                                <i class="fa fa-shopping-cart"></i>
                            </div>
                        </div>
                        <div class="stat-value">3,567</div>
                        <div class="stat-change negative">
                            <i class="fa fa-arrow-down"></i>
                            <span>-3.2% 较上月</span>
                        </div>
                    </div>

                    <div class="stat-card">
                        <div class="stat-header">
                            <div class="stat-title">总收入</div>
                            <div class="stat-icon danger">
                                <i class="fa fa-money"></i>
                            </div>
                        </div>
                        <div class="stat-value">¥128,542</div>
                        <div class="stat-change positive">
                            <i class="fa fa-arrow-up"></i>
                            <span>+15.7% 较上月</span>
                        </div>
                    </div>
                </div>

                <!-- 图表区域 -->
                <div class="charts-container">
                    <div class="chart-card">
                        <h3 class="chart-title">用户增长趋势</h3>
                        <div class="chart-wrapper">
                            <canvas id="growthChart"></canvas>
                        </div>
                    </div>
                    <div class="chart-card">
                        <h3 class="chart-title">订单分布</h3>
                        <div class="chart-wrapper">
                            <canvas id="revenueChart"></canvas>
                        </div>
                    </div>
                </div>

                <!-- 最近活动 -->
                <div class="recent-activities">
                    <h3 class="activity-title">最近活动</h3>
                    <div class="activity-list">
                        <div class="activity-item">
                            <div class="activity-avatar">JD</div>
                            <div class="activity-content">
                                <div class="activity-header">
                                    <span class="activity-name">John Doe</span>
                                    <span class="activity-time">2分钟前</span>
                                </div>
                                <div class="activity-description">登录了系统</div>
                            </div>
                        </div>
                        <div class="activity-item">
                            <div class="activity-avatar">AL</div>
                            <div class="activity-content">
                                <div class="activity-header">
                                    <span class="activity-name">Alice Lee</span>
                                    <span class="activity-time">15分钟前</span>
                                </div>
                                <div class="activity-description">创建了新用户</div>
                            </div>
                        </div>
                        <div class="activity-item">
                            <div class="activity-avatar">BM</div>
                            <div class="activity-content">
                                <div class="activity-header">
                                    <span class="activity-name">Bob Martin</span>
                                    <span class="activity-time">1小时前</span>
                                </div>
                                <div class="activity-description">更新了系统设置</div>
                            </div>
                        </div>
                        <div class="activity-item">
                            <div class="activity-avatar">CS</div>
                            <div class="activity-content">
                                <div class="activity-header">
                                    <span class="activity-name">Carol Smith</span>
                                    <span class="activity-time">3小时前</span>
                                </div>
                                <div class="activity-description">导出了用户报表</div>
                            </div>
                        </div>
                        <div class="activity-item">
                            <div class="activity-avatar">DK</div>
                            <div class="activity-content">
                                <div class="activity-header">
                                    <span class="activity-name">David Kim</span>
                                    <span class="activity-time">5小时前</span>
                                </div>
                                <div class="activity-description">处理了12个订单</div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </main>
    </div>

    <!-- 引入Bootstrap JS -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
    <!-- 图表初始化脚本 -->
    <script>
        // 页面加载完成后执行
        document.addEventListener('DOMContentLoaded', function() {
            // 隐藏加载动画
            const loader = document.querySelector('.loader');
            if (loader) {
                loader.classList.add('hidden');
            }

            // 侧边栏切换功能
            const sidebar = document.getElementById('sidebar');
            const sidebarToggle = document.getElementById('sidebarToggle');
            const mainContent = document.getElementById('mainContent');
            
            if (sidebar && sidebarToggle && mainContent) {
                sidebarToggle.addEventListener('click', function() {
                    sidebar.classList.toggle('collapsed');
                    mainContent.classList.toggle('expanded');
                    
                    // 切换图标
                    const icon = this.querySelector('i');
                    if (sidebar.classList.contains('collapsed')) {
                        icon.classList.remove('fa-angle-left');
                        icon.classList.add('fa-angle-right');
                    } else {
                        icon.classList.remove('fa-angle-right');
                        icon.classList.add('fa-angle-left');
                    }
                });
            }
            
            // 移动端侧边栏切换
            const mobileSidebarToggle = document.getElementById('mobileSidebarToggle');
            if (mobileSidebarToggle && sidebar) {
                mobileSidebarToggle.addEventListener('click', function() {
                    sidebar.classList.toggle('open');
                });
            }
            
            // 用户增长趋势图表
            const growthCtx = document.getElementById('growthChart');
            if (growthCtx) {
                new Chart(growthCtx, {
                    type: 'line',
                    data: {
                        labels: ['一月', '二月', '三月', '四月', '五月', '六月'],
                        datasets: [{
                            label: '用户增长',
                            data: [8500, 9200, 9800, 10500, 11300, 12542],
                            borderColor: '#4f46e5',
                            backgroundColor: 'rgba(79, 70, 229, 0.1)',
                            tension: 0.4,
                            fill: true,
                            pointBackgroundColor: '#4f46e5',
                            pointBorderColor: '#fff',
                            pointBorderWidth: 2,
                            pointRadius: 5
                        }]
                    },
                    options: {
                        responsive: true,
                        maintainAspectRatio: false,
                        plugins: {
                            legend: {
                                display: false
                            }
                        },
                        scales: {
                            y: {
                                beginAtZero: true,
                                grid: {
                                    color: 'rgba(0, 0, 0, 0.05)'
                                }
                            },
                            x: {
                                grid: {
                                    display: false
                                }
                            }
                        }
                    }
                });
            }

            // 收入分布图表
            const revenueCtx = document.getElementById('revenueChart');
            if (revenueCtx) {
                new Chart(revenueCtx, {
                    type: 'doughnut',
                    data: {
                        labels: ['订阅收入', '广告收入', '服务费', '其他'],
                        datasets: [{
                            data: [65, 15, 12, 8],
                            backgroundColor: [
                                '#4f46e5',
                                '#10b981',
                                '#f59e0b',
                                '#ef4444'
                            ],
                            borderWidth: 0,
                            hoverOffset: 10
                        }]
                    },
                    options: {
                        responsive: true,
                        maintainAspectRatio: false,
                        plugins: {
                            legend: {
                                position: 'bottom'
                            }
                        }
                    }
                });
            }
        });
    </script>
</body>
</html>